package com.example.yyy

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter

class mPagerAdapter(fm:FragmentManager,private val goods:MutableList<Goods>):FragmentStatePagerAdapter(fm,
    BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {

    //获取每个页面的碎片对象
    override fun getItem(position: Int): Fragment {
        val item = goods[position]
        return DyFragment.newInstance(position,item.img,item.desc,item.price)
    }

    //获取页面数
    override fun getCount(): Int = goods.size

    override fun getPageTitle(position: Int): CharSequence? = goods[position].title
}